# -*- coding:utf-8 -*-
import Configuration as cfg
import matplotlib.pyplot as plt
import pandas as pd
import time

pro = cfg.getDataApi()
ts = cfg.getTushare()

print(ts.__version__)

# df = pro.daily(ts_code='002291.SZ', start_date='20170901')
# print(type(df))
# print("----------------")
# print(df.columns)
# print(df)
# print(df["low"])

# plt.plot(df["low"])
# plt.show()

# time：时间
# price：当前价格
# pchange:涨跌幅
# change：价格变动
# volume：成交手
# amount：成交金额(元)
# type：买卖类型【买盘、卖盘、中性盘】
# df = ts.get_today_ticks('000921')
# df = df.to_csv("000921.csv", encoding="utf-8")

df = pd.read_csv("000921.csv", index_col = 'trade_date', parse_dates = True)
df = df.head(5)
# df = df.sort_values(by = ['trade_date'],axis = 0,ascending = False)
# print(df.columns)

for idx, row in df.iterrows():
  print(idx)
#   df.loc[idx,'trade_date'] = time.strftime("%Y-%m-%d %H:%M:%S", time.strptime(str(row['trade_date']), "%Y%m%d")) + ".005"

# print(df['trade_date'])

# df['trade_date'].apply(lambda datestr:time.strftime("%Y-%m-%d %H:%M:%S", time.strptime(str(datestr), "%Y%m%d")))
# print(df['trade_date'])
# df = df.sort_index(ascending = True)
# print(df.head(20))









